package pers.zh.parking.mvp.model;

import android.app.Application;

import com.google.gson.Gson;

import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;
import pers.zh.parking.common.ApiService;
import pers.zh.parking.common.BaseResponse;
import pers.zh.parking.data.entity.Notice;
import pers.zh.parking.mvp.contract.NoticeManageContract;

@ActivityScope
public class NoticeManageModel extends BaseModel implements NoticeManageContract.Model {

    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public NoticeManageModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<BaseResponse<List<Notice>>> getNotice() {
        return mRepositoryManager.obtainRetrofitService(ApiService.class).getNotice();
    }

    @Override
    public Observable<BaseResponse> addNotice(Notice notice) {
        return mRepositoryManager.obtainRetrofitService(ApiService.class).addNotice(notice);
    }

    @Override
    public Observable<BaseResponse> updateNotice(Notice notice) {
        return mRepositoryManager.obtainRetrofitService(ApiService.class).updateNotice(notice);
    }

    @Override
    public Observable<BaseResponse> deleteNotice(List<Notice> list) {
        return mRepositoryManager.obtainRetrofitService(ApiService.class).deleteNotice(list);
    }
}